package com.qianfeng.job;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

public class TestJob {


    public static void main(String[] args) throws SchedulerException {

        //创建Job对象
        JobDetail jobDetail = JobBuilder.newJob(HelloJob.class).build();
        //创建触发器Trigger,每5秒钟触发一次任务
        Trigger Trigger = TriggerBuilder.newTrigger().withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(5)).build();
        //创建任务调度(Scheduler)对象
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        //将任务和触发器整合到一起
        scheduler.scheduleJob(jobDetail,Trigger);
        //启动
        scheduler.start();

    }
}
